﻿using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ESRI.ArcGIS.Geodatabase;
using PlanningGIS.Util;
using PlanningGIS.ArcGIS.Custom;
using PlanningGIS.MapSheet;
using PlanningGIS.Framework.Config;
using PlanningGIS.Util.Net;
using PlanningGIS.Framework;
using PlanningGIS.MetaData;
using System.ComponentModel;

namespace PlanningGIS.Product
{
    /// <summary>
    /// 产品配置信息
    /// </summary>
    [Serializable]
    public class ProductConfig
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public ProductConfig()
        {
            ProType = zjgisProType.UnKnow;
        }

        /// <summary>
        /// 获取或设置Las数据空间参考名称
        /// </summary>
        [DataMember]
        public string LasSpatialName { get; set; }

        /// <summary>
        /// 获取或设置图廓图层名称
        /// </summary>
        [DataMember]
        public string TKName { get; set; }

        /// <summary>
        /// 获取或设置产品数据调图路径
        /// </summary>
        [DataMember]
        public string DataViewPath { get; set; }

        /// <summary>
        /// 获取或设置产品数据存储类型
        /// </summary>
        [DataMember]
        [System.ComponentModel.DefaultValue(zjgisProType.UnKnow)]
        public zjgisProType ProType { get; set; }

        /// <summary>
        /// 数据类型
        /// </summary>
        public List<MetaDataType> DataTypes { get; set; }

        /// <summary>
        /// 保存修改后的产品配置信息
        /// </summary>
        public void Save()
        {
            ConfigHelper.SaveObject<ProductConfig>(this);
        }

        /// <summary>
        /// 析构函数
        /// </summary>
        ~ProductConfig()
        {
            ProductHelper.Ftp = null;
            string localPath = AppConfig.SystemConfig.FTP.LocalPath;
            if (Directory.Exists(localPath)) NetFileService.Disconnect(localPath);
            if (!string.IsNullOrWhiteSpace(DataViewPath) && Directory.Exists(DataViewPath))
            {
                try
                {
                    Directory.Delete(DataViewPath);
                }
                catch
                {
                    
                }
                
            }
        }
    }

}
